package com.xuanapi.xuanpicturebackend.common;

import com.xuanapi.xuanpicturebackend.exception.ErrorCode;
import lombok.Data;

import java.io.Serializable;

/***
 *@title BaseResponse
 *@description 全局响应封装类
 *@author 冰点
 *@version 1.0.0
 *@create 2025/2/8 9:52
 **/
@Data
public class BaseResponse<T> implements Serializable {

    private int code;

    private T data;

    private String message;


    public BaseResponse(int code, T data, String message) {
        this.code = code;
        this.message = message;
        this.data = data;
    }


    public BaseResponse(int code, T data) {
        this(code,data,"");
    }

    public BaseResponse(ErrorCode errorCode) {
        this(errorCode.getCode(),null,errorCode.getMessage());
    }

}
